mui.init({
    swipeBack: false,
    pullRefresh: {
        container: "#refreshContainer", //下拉刷新容器标识，querySelector能定位的css选择器均可，比如：id、.class等
        down: {
            style: 'circle', //必选，下拉刷新样式，目前支持原生5+ ‘circle’ 样式
            color: '#2BD009', //可选，默认“#2BD009” 下拉刷新控件颜色
            height: '50px', //可选,默认50px.下拉刷新控件的高度,
            range: '100px', //可选 默认100px,控件可下拉拖拽的范围
            offset: '0px', //可选 默认0px,下拉刷新控件的起始位置
            auto: false, //可选,默认false.首次加载自动上拉刷新一次
            callback: function () {
                news_lists.gemodule();
                setTimeout(function () {
                    mui('#refreshContainer').pullRefresh().endPulldownToRefresh(false);
                }, 1000)
            }
        }
    }
});


document.querySelector('.icon_top_sr').addEventListener('tap',function(){
	mui.openWindow({
        url: '../search/keywords.html',
        show: {
            autoShow: true,
            aniShow: 'slide-in-top',
            duration: 100
        },
        waiting: {
            autoShow: false,
        }
    });
});
var news_lists;
mui.plusReady(function () {
	hideScrollBar();
    var api_host = plus.storage.getItem('HOST_URL');
    news_lists = new Vue({
        el: '#list_box',
        data: {
            zixun_list: '',
            zhenti_list: '',
            tixing_list: '',
            jujiao_list: ''
        },
        mounted() {
            this.gemodule();
        },
        methods: {
            gemodule:function(){
                var self = this;
                mui.getJSON("../../../manifest.json",null,function(data) {
                    mui.ajax({
                        url: api_host + '/api/other/other/getAppModule',
                        dataType: 'json',
                        data: {
                            'versionNum': data.version.code,
                        },
                        type: 'get',
                        timeout: 3000,
                        success: function (msg) {
                            if (msg.code == 1) {
                                if (msg.data.search == 0) {
                                    $('.icon_top_sr').css('display', 'none');
                                } else {
                                    $('.icon_top_sr').css('display', 'block');
                                }
                            }
                            self.getclass_details();
                        },
                        error: function (xhr, type, errorThrown) {
                            self.getclass_details();
                        }
                    });
                })
            },
            getclass_details: function () {
                showWatting();
                mui.ajax({
                    url: api_host + '/api/linxuan/news/infomation',
                    dataType: 'json',
                    type: 'get',
                    timeout: 10000,
                    success: function (msg) {
                        news_lists.zixun_list = msg.data.zixun;
                        news_lists.zhenti_list = msg.data.zhenti;
                        news_lists.tixing_list = msg.data.tixing;
                        news_lists.jujiao_list = msg.data.jujiao;
                    },
                    error: function () {
                        console.log('首次打开专栏列表出错了');
                    },
                    complete: function () {
                        news_lists.getSheng();
                        plus.nativeUI.closeWaiting();
                    }
                })
            },
            getSheng: function () {
                mui.ajax({
                    url: api_host + '/api/linxuan/news/getarea',
                    dataType: 'json',
                    type: 'get',
                    success: function (data) {
                        if (data.code == 1) {
                            plus.storage.setItem('area', JSON.stringify(data.data))
                        } else {
                            console.log(data.msg);
                        }
                    },
                    error: function (xhr, type, errorThrown) {
                        console.log('获取省份信息失败！')
                    },
                    complete: function () {
                        news_lists.getZhiwei();
                    }
                });
            },
            getZhiwei: function () {
                var api_host = plus.storage.getItem('HOST_URL');
                mui.ajax({
                    url: api_host + '/api/linxuan/news/zhiwei',
                    dataType: 'json',
                    type: 'get',
                    async: true,
                    timeout: 3000,
                    success: function (msg) {
                        if (msg.code == 1) {
                            plus.storage.setItem('zhiwei', JSON.stringify(msg.data));
                        } else {
                            console.log(msg.msg);
                        }
                    },
                    error: function () {
                        console.log('获取区域信息失败');
                    }
                })
            },
            open_news_detail: function (dataID) {
                mui.openWindow({
                    url: '../news/detail.html',
                    extras: {
                        'newsid': dataID
                    },
                    show: {
                        autoShow: true,
                        aniShow: 'pop-in',
                        duration: 400
                    },
                    waiting: {
                        autoShow: false,
                    }
                });
            },
            open_zixun: function () {
                mui.openWindow({
                    url: '../news/columnTab.html',
                    createNew:false,
                    show: {
                        autoShow: true,
                        aniShow: 'pop-in',
                        duration: 400
                    },
                    waiting: {
                        autoShow: false,
                    }
                })
            },
            open_zhenti: function () {
                mui.openWindow({
                    url: '../news/lxzt_Tab.html',
                    createNew:false,
                    show: {
                        autoShow: true,
                        aniShow: 'pop-in',
                        duration: 400
                    },
                    waiting: {
                        autoShow: false,
                    }
                })
            },
            open_tixing: function () {
                mui.openWindow({
                    url: '../news/cktx_Tab.html',
                    createNew:false,
                    show: {
                        autoShow: true,
                        aniShow: 'pop-in',
                        duration: 400
                    },
                    waiting: {
                        autoShow: false,
                    }
                })
            },
            open_jujiao: function () {
                mui.openWindow({
                    url: '../news/kdjj_Tab.html',
                    createNew:false,
                    show: {
                        autoShow: true,
                        aniShow: 'pop-in',
                        duration: 400
                    },
                    waiting: {
                        autoShow: false,
                    }
                })
            },
            open_more_zixun: function () {
                mui.openWindow({
                    url: '../news/columnTab.html'
                })
            },
            open_more_zhenti: function () {
                mui.openWindow({
                    url: '../news/lxzt_Tab.html'
                })
            },
            open_more_tixing: function () {
                mui.openWindow({
                    url: '../news/cktx_Tab.html'
                })
            },
            open_more_jujiao: function () {
                mui.openWindow({
                    url: '../news/kdjj_Tab.html'
                })
            }
        }
    })
})